package com.ruanko.service.impl;


import java.util.ArrayList;
import java.util.List;

import com.ruanko.dao.UserInfoDao;
import com.ruanko.dao.impl.UserInfoDaoImpl;
import com.ruanko.entity.UserInfoBean;
import com.ruanko.service.UserInfoService;

public class UserInfoServiceImpl implements UserInfoService{
	
	private UserInfoDao userInfoDao;

	public UserInfoServiceImpl() {
		this.userInfoDao = new UserInfoDaoImpl();
	}

	public boolean login(UserInfoBean userInfoBean) {
		
		boolean b = false;
		UserInfoBean userInfo = userInfoDao.getUserResult(userInfoBean.getUserId());
		if(userInfo.getUserId().equals(userInfoBean.getUserId())){
			if(userInfo.getPwd().equals(userInfoBean.getPwd()))
				b = true;
		}
		return b;
	}

	public boolean register(UserInfoBean userInfoBean) {
		
		boolean b = false;
		ArrayList<UserInfoBean> userInfoList = new ArrayList<UserInfoBean>();
		userInfoList.add(userInfoBean);
		b = userInfoDao.insertUserInfo(userInfoList);
		return b;
	}

	public boolean deleteUserInfo(List<UserInfoBean> userInfoList) {
		boolean b = false;
		b = userInfoDao.deleteUserInfo(userInfoList);
		return b;
	}

	public boolean updateUserInfo(List<UserInfoBean> userInfoList) {
		boolean b = false;
		b = userInfoDao.updateUserInfo(userInfoList);
		return b;
	}

	public List<UserInfoBean> getUserInfoList() {
		List<UserInfoBean> userInfoList = userInfoDao.getUserResult();
		return userInfoList;
	}
	public List<UserInfoBean> getUserInfoByPage(int pageSize,int pageNow) {
		List<UserInfoBean> userInfoList = userInfoDao.queryByPage(pageSize, pageNow);
		return userInfoList;
	}
}
